package me.wsj.demo;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*Tester tester = new Tester();
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            new Thread(() -> {
                tester.doSth(finalI);
            }).start();
        }*/

        ServiceConnection conn = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {

            }

            @Override
            public void onServiceDisconnected(ComponentName name) {

            }
        };

        Intent intent = new Intent(this, MyService.class);
        bindService(intent, conn, BIND_AUTO_CREATE);

        findViewById(R.id.tvStop).setOnClickListener(v -> {
            Intent second = new Intent(this, Main2Activity.class);
            startActivity(second);
        });


    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        Log.e("wsjLib","onRestoreInstanceState");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("wsjLib","onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("wsjLib","onStop");
    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.e("wsjLib","onSaveInstanceState");
    }
}
